const mongoose = require("./db");

const saoSchema = new mongoose.Schema({
    title: String,
    content: String,
    img: String,
    type: String,
    price: Number,
    bookname: String,
}, {
    versionKey: false
});
// 发布闲置
const publicSchema = new mongoose.Schema({
    title: String,
    content: String,
    img: String,
    type: String,
    price: Number,
    status: {
        type: Boolean,
        default: false
    }
}, {
    versionKey: false
});

const imgSchema = new mongoose.Schema({
    img: String,
    pid: {
        type: mongoose.Types.ObjectId,
        ref: 'public'
    }
})

// 收货地址
const addressSchema = new mongoose.Schema({
    addr_name: String,
    phone: String,
    addr: String,
})


const saoModel = mongoose.model('sao', saoSchema, 'sao')
const publicModel = mongoose.model('public', publicSchema, 'public')
const addressModel = mongoose.model('address', addressSchema, 'address')
const imgModel = mongoose.model('img', imgSchema, 'img')


module.exports = { saoModel, publicModel, addressModel, imgModel };
